package com.dau.api.controller;

import com.dau.api.annotation.RepeatSubmit;
import com.dau.api.annotation.SemaphoreLimit;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("api")
public class HelloWordController {
    @SemaphoreLimit(limitKey ="semaphoreKey", value =3)
    @RequestMapping("test")
    @RepeatSubmit(interval = 1500, timeUnit = TimeUnit.MILLISECONDS)
    public String helloWord() throws InterruptedException {
        //假设业务处理了1秒
        TimeUnit.SECONDS.sleep(1);
        return "success";
    }
}
